package com.freak.neteasecloudmusic.modules.mine.fragment.adapter;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.freak.neteasecloudmusic.R;
import com.freak.neteasecloudmusic.modules.mine.entity.MinePlayListEntity;
import com.freak.neteasecloudmusic.modules.mine.entity.PersonFmEntity;

import java.util.List;

public class MyMusicAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {
    private Context context;

    public final static int ITEM_MY_MUSCI_FM = 1;

    public MyMusicAdapter(List<MultiItemEntity> data, Context context) {
        super(data);
        this.context = context;
        addItemType(MySongListAdapter.ITEM_CONTEXT, R.layout.view_item_my_music_like);
        addItemType(ITEM_MY_MUSCI_FM, R.layout.view_item_my_music_fm);
    }


    @Override
    protected void convert(@NonNull BaseViewHolder helper, MultiItemEntity item) {
        switch (helper.getItemViewType()) {
            case MySongListAdapter.ITEM_CONTEXT:
                MinePlayListEntity.PlaylistBean playlistBean = (MinePlayListEntity.PlaylistBean) item;
                Glide.with(context).load(playlistBean.getCoverImgUrl()).thumbnail(0.1f).into((ImageView) helper.getView(R.id.circularBeadClipPathImageViewItemLike));
                break;
            case ITEM_MY_MUSCI_FM:
                PersonFmEntity.DataBean personFmEntity = (PersonFmEntity.DataBean) item;
                Glide.with(context).load(personFmEntity.getAlbum().getBlurPicUrl()).fitCenter().thumbnail(0.1f).into((ImageView) helper.getView(R.id.circularBeadClipPathImageViewItemFm));
                break;
        }

    }
}
